package com.baizhi.controller;


import com.baizhi.entity.LayuiResource;
import com.baizhi.entity.TreeNode;
import com.baizhi.service.LayuiResourceService;
import org.apache.shiro.SecurityUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author zhengg
 * @since 2020-07-31
 */
@RestController
@RequestMapping("/layui-resource")
public class LayuiResourceController {
    @Autowired
    private LayuiResourceService rs;
    @RequestMapping("/selectMenuByUsername")
    public List<LayuiResource> selectMenuByUsername(){
        //通过shiro获取到当前user对象
        String username = (String) SecurityUtils.getSubject().getPrincipal();
        List<LayuiResource> layuiResources = rs.selectMenuByUsername(username);
        //过滤出集合里面的type值为menu的所有 数据
        return layuiResources;
    }
    @RequestMapping("/selectResTree")
    public List<TreeNode> selectResTree(){
        return rs.selectResTree();
    }
}
